import React from 'react';

function ppHOC(WrappedComponent) {
  return class PP extends React.PureComponent {
    constructor(props) {
      super(props);
      this.state = {
        name: ''
      };
      this.handleChange = this.handleChange.bind(this);
    }

    handleChange(event) {
      this.setState({
        name: event.target.value,
      });
    }

    render() {
      const newProps = {
        name: {
          value: this.state.name,
          onChange: this.handleChange
        }
      };
      return <WrappedComponent {...this.props} {...newProps}/>;
    }
  }
}
